﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Linq;

namespace MVVMGrid.UsingReactive.Models
{
    public static class GridDataExtensions
    {
        private static Random randGen = new Random();
        private static int nextID = 1001;

        public static string RandomWord()
        {
            return new String( (char)( randGen.Next( 26 ) + 'A' ), randGen.Next( 12 ) + 1 );
        }

        public static string RandomWords()
        {
            string[] words = new string[randGen.Next( 5 ) + 1];
            for( int i = 0; i < words.Length; i++ )
                words[i] = RandomWord();
            return String.Join( " ", words );
        }

        public static void AddRandomData( this GridData gridData )
        {
            gridData.One = ++nextID;
            gridData.Two = RandomWord();
            gridData.Three = ( randGen.Next( 2 ) == 0 );
            gridData.Four = RandomWords();
            gridData.Five = DateTime.Now.AddMinutes( randGen.NextDouble() * 3600.0 );
        }

        public static void AddRandomData( this GridDataCollection gridDataCollection, int recordCount )
        {
            for( int i = 0; i < recordCount; i++ )
            {
                GridData gridData = new GridData();
                gridData.AddRandomData();
                gridDataCollection.Add(gridData);
            }
        }
    }
}
